﻿using Inovout.Cloud.DataWarehouse.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Cloud.DataWarehouse.Utility
{
    public class DataTypeMapping
    {
        public static bool StringTOBool(string str) 
        {
            bool boolValue = false;
            if ("YES".Equals(str))
            {
                boolValue = true;
            }
            return boolValue;
        }
        public static DataViewPropertyType Transform(string dataType)
        {
            DataViewPropertyType dataViewPropertyType = DataViewPropertyType.String;
            switch (dataType) 
            {
                case "int":
                    dataViewPropertyType = DataViewPropertyType.Int32;
                    break;
                case "datetime":
                    dataViewPropertyType = DataViewPropertyType.DateTime;
                    break;
                case "bit":
                    dataViewPropertyType = DataViewPropertyType.Bool;
                    break;
                case "varbinary":
                    dataViewPropertyType = DataViewPropertyType.ByteArray;
                    break;
                default :
                    break;
            }

            return dataViewPropertyType;
        }

        public static string GetNHibernateTypeByDataType(DataViewPropertyType dataViewPropertyType) 
        {
            string type = "string";
            switch (dataViewPropertyType) 
            {
                case DataViewPropertyType.Bool:
                    type = "Boolean";
                    break;
                case DataViewPropertyType.ByteArray:
                    type = "string";
                    break;
                case DataViewPropertyType.DateTime:
                    type = "DateTime";
                    break;
                case DataViewPropertyType.Double:
                    type = "Double";
                    break;
                case DataViewPropertyType.Int16:
                    type = "Int16";
                    break;
                case DataViewPropertyType.Int32:
                    type = "Int32";
                    break;
                case DataViewPropertyType.Int64:
                    type = "Int64";
                    break;
                default:
                    type = "string";
                    break;
            }
            return type;
        }
    }
}
